﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.ServiceModel;
using COFE.Data;
using COFE.Core;
using COFE.Core.Profile;
using COFE.Core.Utils;

namespace COFE.Web
{
    /// <summary>
    /// WCF related tools.
    /// </summary>
    public static class WCFUtils
    {
        /// <summary>
        /// Gets the host of incoming request.
        /// </summary>
        public static string GetHost()
        {
            if (OperationContext.Current == null)
                return "";

            Uri uri = OperationContext.Current.IncomingMessageHeaders.To;
            if (uri.Port == 80)
                return String.Format("{0}://{1}", uri.Scheme, uri.Host);
            else return String.Format("{0}://{1}:{2}", uri.Scheme, uri.Host, uri.Port);
        }        

        /// <summary>
        /// Gets the current user.
        /// </summary>
        /// <returns></returns>
        public static string GetUser()
        {
            return "TESTUSER";
        }

        
              
    }

}
